package com.product.android.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
import android.view.KeyEvent;

import com.nd.android.u.allcommon.R;
import com.product.android.business.ApplicationVariable;
import com.product.android.commonInterface.allCommonInterfaceImpl.AllCommonCallOtherModel;

public class UserIdentityDialog {
	private static final String TAG = "PubFunction";

	/*
	 * 强制下线弹出对话框
	 */
	public static void dialogForceOffline(final Activity context) {
		new AlertDialog.Builder(context)
				.setTitle(R.string.forced_offline_login_again)
				.setIcon(android.R.drawable.ic_dialog_info)
				.setPositiveButton(android.R.string.ok,
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								ApplicationVariable.INSTANCE.isForceOffline=false;
                                AllCommonCallOtherModel.MainModel.toLoginActivity(context);
							}
						}).setCancelable(false)
				.setOnKeyListener(new OnKeyListener() {
					@Override
					public boolean onKey(DialogInterface dialog, int keyCode,
							KeyEvent event) {
						if (keyCode == KeyEvent.KEYCODE_SEARCH) {
							return true;
						} else {
							return false;
						}
					}
				}).show();
	}

	/*
	 * 身份过期弹出对话框
	 */
	public static void dialogIdentityExpired(final Activity context) {
		new AlertDialog.Builder(context)
				.setTitle(R.string.identity_expired_login_again)
				.setIcon(android.R.drawable.ic_dialog_info)
				.setPositiveButton(android.R.string.ok,
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								ApplicationVariable.INSTANCE.isIdentityExpired=false;
								AllCommonCallOtherModel.MainModel.toLoginActivity(context);
							}
						}).setCancelable(false)
				.setOnKeyListener(new OnKeyListener() {
					@Override
					public boolean onKey(DialogInterface dialog, int keyCode,
							KeyEvent event) {
						if (keyCode == KeyEvent.KEYCODE_SEARCH) {
							return true;
						} else {
							return false;
						}
					}
				}).show();
	}

}
